package com.slicktechnologies.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.simplesoftwares.client.library.FlexForm;
import com.simplesoftwares.client.library.FormField;
import com.simplesoftwares.client.library.FormFieldBuilder;
import com.simplesoftwares.client.library.FlexForm.FormStyle;
import com.simplesoftwares.client.library.appskeleton.AppMemory;
import com.simplesoftwares.client.library.libservice.RegisterService;
import com.simplesoftwares.client.library.libservice.RegisterServiceAsync;
import com.simplesoftwares.client.library.libservice.SMSService;
import com.simplesoftwares.client.library.libservice.SMSServiceAsync;
import com.slicktechnologies.client.login.LoginPresenter;
import com.slicktechnologies.client.utility.AppConnector;
import com.slicktechnologies.client.utility.AppUtility;
import com.slicktechnologies.client.utility.Screen;
import com.slicktechnologies.client.views.home.HomePresenter;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Slick_Erp implements EntryPoint 
{
	public static String companyname="";
	public void onModuleLoad()
	{
		
		AppConnector.initalizes();
		AppMemory mem=AppMemory.getAppMemory();
		mem.initialingapp();
		AppMemory.getAppMemory().setCurrentScreenandChangeProcessName("DashBoard/Home", Screen.HOME);
		HomePresenter.initalize();
		
		
		
		/*RegisterServiceAsync registerservice=GWT.create(RegisterService.class);
		final NameServiceAsync service=GWT.create(NameService.class);
		String[] spliturl;
		String url=Window.Location.getHref();
		url=url.replaceAll("http://","");
		if(url.contains("127")||url.contains("slicktechnologies-pc:"))
			spliturl="http://www.ganesh.evasoftwaresolutions.com/".split("\\.");
		else
		   spliturl=url.split("\\.");
		
		
		for(int i=0;i<spliturl.length;i++)
		{
			System.out.println("Url is "+spliturl[i]+" "+i);
			if(spliturl[i].equals("evasoftwaresolutions"))
			{
				
				companyname=spliturl[i-1];
				System.out.println("Company Name is "+companyname);
				break;
			}
		}
		
		registerservice.registerClass(new AsyncCallback<Void>() {
			
			@Override
			public void onSuccess(Void result) 
			{
				
				
				
				service.getClientName(companyname,new AsyncCallback<String>() {

					@Override
					public void onFailure(Throwable caught) {
					   Window.alert("Company Not Registered !");
						
					}

					@Override
					public void onSuccess(String result) {
						if(result==null)
						{
							Window.alert("Company Not Registered !");
						}
						else
						{
						
							//AppUtility.createLogin(result);
						}
						  
						
					}
				});
				
				
		
				
			}
			
			@Override
			public void onFailure(Throwable caught) {
				
				
			}
		});
		
		
	  */
		
	}
	
	
}
